<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="物料编号" prop="goodsId">
        <el-input
          v-model="queryParams.goodsId"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="goodsName">
        <el-input
          v-model="queryParams.goodsName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料简称 简码" prop="goodsShortName">
        <el-input
          v-model="queryParams.goodsShortName"
          placeholder="请输入物料简称 简码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="助记码" prop="pyName">
        <el-input
          v-model="queryParams.pyName"
          placeholder="请输入助记码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="条形码" prop="barcode">
        <el-input
          v-model="queryParams.barcode"
          placeholder="请输入条形码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分类" prop="goodsTypeId">
        <el-input
          v-model="queryParams.goodsTypeId"
          placeholder="请输入分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格" prop="specification">
        <el-input
          v-model="queryParams.specification"
          placeholder="请输入规格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="型号" prop="model">
        <el-input
          v-model="queryParams.model"
          placeholder="请输入型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单价" prop="price">
        <el-input
          v-model="queryParams.price"
          placeholder="请输入单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item label="物料单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入物料单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     
      <el-form-item label="产地" prop="produceArea">
        <el-input
          v-model="queryParams.produceArea"
          placeholder="请输入产地"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item label="供应商编号" prop="providerId">
        <el-input
          v-model="queryParams.providerId"
          placeholder="请输入供应商编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="海关编码 " prop="hsnumber">
        <el-input
          v-model="queryParams.hsnumber"
          placeholder="请输入海关编码 "
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="ABC分类" prop="abc">
        <el-input
          v-model="queryParams.abc"
          placeholder="请输入ABC分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="危险品" prop="hazardous">
        <el-select v-model="queryParams.hazardous" placeholder="请选择危险品" clearable>
          <el-option
            v-for="dict in dict.type.hazardous"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      
      
      <el-form-item label="版本" prop="version">
        <el-input
          v-model="queryParams.version"
          placeholder="请输入版本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建人" prop="createMan">
        <el-input
          v-model="queryParams.createMan"
          placeholder="请输入创建人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createDate">
        <el-date-picker clearable
          v-model="queryParams.createDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="修改人" prop="updateMan">
        <el-input
          v-model="queryParams.updateMan"
          placeholder="请输入修改人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="修改时间" prop="updateDate">
        <el-date-picker clearable
          v-model="queryParams.updateDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择修改时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否是组合商品" prop="scFlag">
        <el-select v-model="queryParams.scFlag" placeholder="请选择是否是组合商品" clearable>
          <el-option
            v-for="dict in dict.type.sc_flag"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
    
    
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:goods:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:goods:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:goods:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:goods:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

      <el-table border
      ref="filterTable" v-loading="loading" :data="GOODSList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column sortable fixed label="物料编号" align="center" prop="goodsId" />
        <el-table-column label="物料名称" align="center" prop="goodsName" />
        <el-table-column label="物料简称" align="center" prop="goodsShortName" />
        <el-table-column sortable label="助记码" align="center" prop="pyName" />
        <el-table-column label="分类" align="center" prop="goodsTypeId" />
        <el-table-column label="规格" align="center" prop="SPECIFICATION" />
        <el-table-column label="型号" align="center" prop="MODEL" />
        <el-table-column sortable label="单价" align="center" prop="PRICE" />
        <el-table-column label="条形码" align="center" prop="BARCODE" />
        <el-table-column sortable label="长" align="center" prop="GLENGTH" />
        <el-table-column sortable label="宽" align="center" prop="GWIDTH" />
        <el-table-column sortable label="高" align="center" prop="GHEIGHT" />
        <el-table-column sortable label="体积" align="center" prop="GVOLUME" />
        <el-table-column label="商品重量单位" align="center" prop="scaleUnit" />
        <el-table-column label="物料单位" align="center" prop="UNIT" />
        <el-table-column sortable label="库存上限" align="center" prop="warnUp" />
        <el-table-column sortable label="库存下限" align="center" prop="warnDown" />
        <el-table-column label="产地" align="center" prop="produceArea" />
        <el-table-column sortable label="毛重" align="center" prop="grossWeight" />
        <el-table-column sortable label="净重" align="center" prop="netWeight" />
        <el-table-column label="供应商编号" align="center" prop="providerId" />
        <el-table-column label="海关编码" align="center" prop="HSNUMBER" />
        <el-table-column label="ABC分类" align="center" prop="ABC" />
        <el-table-column label="危险品" align="center" prop="HAZARDOUS">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.hazardous" :value="scope.row.HAZARDOUS"/>
          </template>
        </el-table-column>
        <el-table-column label="存储条件" align="center" prop="STORED" />
        <el-table-column sortable label="保质期" align="center" prop="PERIOD" />
        <el-table-column label="保质期单位" align="center" prop="PERIODUNIT" />
        <el-table-column sortable label="增值税" align="center" prop="ADDTAX" />
        <el-table-column label="季节" align="center" prop="SEASON" />
        <el-table-column sortable label="关税税率" align="center" prop="TARIFFRATE" />
        <el-table-column label="备注" align="center" prop="REMARK" />
        <el-table-column label="状态" align="center" prop="STATUS">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.status" :value="scope.row.STATUS"/>
          </template>
        </el-table-column>
        <el-table-column label="版本" align="center" prop="VERSION" />
        <el-table-column label="图片" align="center" prop="IMG" width="100">
          <template slot-scope="scope">
            <image-preview :src="scope.row.IMG" :width="50" :height="50"/>
          </template>
        </el-table-column>
        <el-table-column label="创建人" align="center" prop="createMan" />
        <el-table-column sortable label="创建时间" align="center" prop="createDate" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="修改人" align="center" prop="updateMan" />
        <el-table-column sortable label="修改时间" align="center" prop="updateDate" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="是否是组合商品 0否 1是" align="center" prop="scFlag">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sc_flag" :value="scope.row.scFlag"/>
          </template>
        </el-table-column>
        <el-table-column sortable label="成本价" align="center" prop="costPrice" />
        <el-table-column label="IS_OPEN" align="center" prop="isOpen" />
        <el-table-column label="STORAGE_AREA_ID" align="center" prop="storageAreaId" />
        <el-table-column label="ZH_FlAG" align="center" prop="zhFlag" />
        <el-table-column label="SEMISTS" align="center" prop="SEMISTS" />
        <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['system:GOODS:edit']"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:GOODS:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
  
      <!-- 添加或修改物料对话框 -->
      <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
       
        <el-row >
          <!-- 每个el-col是一个栅格单元，span="12"表示占据12/24的宽度，即一半 -->
          <el-col :span="12">
            <el-form-item label="物料编号"  prop="goodsId">
              <el-input v-model="form.goodsId" placeholder="请输入物料编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="goodsName">
              <el-input v-model="form.goodsName" type="textarea" placeholder="请输入内容"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="物料简称 简码" prop="goodsShortName">
              <el-input v-model="form.goodsShortName" placeholder="请输入物料简称 简码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="助记码" prop="pyName">
              <el-input v-model="form.pyName" placeholder="请输入助记码"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="条形码" prop="BARCODE">
              <el-input v-model="form.BARCODE" placeholder="请输入条形码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="分类" prop="goodsTypeId">
              <el-input v-model="form.goodsTypeId" placeholder="请输入分类"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="规格" prop="SPECIFICATION">
              <el-input v-model="form.SPECIFICATION" placeholder="请输入规格"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="型号" prop="MODEL">
              <el-input v-model="form.MODEL" placeholder="请输入型号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="单价" prop="price">
              <el-input v-model="form.price" placeholder="请输入单价"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="长" prop="glength">
              <el-input v-model="form.glength" placeholder="请输入长"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="宽" prop="gwidth">
              <el-input v-model="form.gwidth" placeholder="请输入宽"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="高" prop="gheight">
              <el-input v-model="form.gheight" placeholder="请输入高"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="图号" prop="recoil">
              <el-input v-model="form.recoil" placeholder="请输入图号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="体积" prop="gvolume">
              <el-input v-model="form.gvolume" placeholder="请输入体积"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="商品重量单位" prop="scaleUnit">
              <el-input v-model="form.scaleUnit" placeholder="请输入商品重量单位"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料单位" prop="UNIT">
              <el-input v-model="form.UNIT" placeholder="请输入物料单位"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="库存上限" prop="warnUp">
              <el-input v-model="form.warnUp" placeholder="请输入库存上限"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库存下限" prop="warnDown">
              <el-input v-model="form.warnDown" placeholder="请输入库存下限"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="产地" prop="produceArea">
              <el-input v-model="form.produceArea" placeholder="请输入产地"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="毛重" prop="grossWeight">
              <el-input v-model="form.grossWeight" placeholder="请输入毛重"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="净重" prop="netWeight">
              <el-input v-model="form.netWeight" placeholder="请输入净重"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商编号" prop="providerId">
              <el-input v-model="form.providerId" placeholder="请输入供应商编号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="海关编码" prop="HSNUMBER">
              <el-input v-model="form.HSNUMBER" placeholder="请输入海关编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="ABC分类" prop="ABC">
              <el-input v-model="form.ABC" placeholder="请输入ABC分类"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="危险品   0否 1是" prop="HAZARDOUS">
              <el-select v-model="form.HAZARDOUS" placeholder="请选择危险品   0否 1是">
            <el-option
              v-for="dict in dict.type.hazardous"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="存储条件" prop="STORED">
              <el-input v-model="form.STORED" placeholder="请输入存储条件"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="保质期" prop="period">
              <el-input v-model="form.period" placeholder="请输入保质期"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保质期单位" prop="PERIODUNIT">
              <el-input v-model="form.PERIODUNIT" placeholder="请输入保质期单位"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="增值税" prop="addtax">
              <el-input v-model="form.addtax" placeholder="请输入增值税"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="季节" prop="SEASON">
              <el-input v-model="form.SEASON" placeholder="请输入季节"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="关税税率" prop="tariffrate">
              <el-input v-model="form.tariffrate" placeholder="请输入关税税率"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="REMARK">
              <el-input v-model="form.REMARK" placeholder="请输入内容"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="版本" prop="VERSION">
              <el-input v-model="form.VERSION" placeholder="请输入版本"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="图片" prop="IMG">
              <image-upload v-model="form.IMG"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="是否是组合商品 0否 1是" prop="scFlag">
              <el-select v-model="form.scFlag" placeholder="请选择是否是组合商品 0否 1是">
            <el-option
              v-for="dict in dict.type.sc_flag"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="成本价" prop="costPrice">
              <el-input v-model="form.costPrice" placeholder="请输入成本价" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="customerId" prop="customerId">
              <el-input v-model="form.customerId" placeholder="请输入customerId"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="sts1" prop="sts1">
              <el-input v-model="form.sts1" placeholder="请输入sts1"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="isOpen" prop="isOpen">
              <el-input v-model="form.isOpen" placeholder="请输入isOpen"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="storageAreaId" prop="storageAreaId">
              <el-input v-model="form.storageAreaId" placeholder="请输入storageAreaId"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="zhFlag" prop="zhFlag">
              <el-input v-model="form.zhFlag" placeholder="请输入zhFlag"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="semists" prop="semists">
              <el-input v-model="form.semists" placeholder="请输入semists"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="materialCharacteristics" prop="materialCharacteristics">
              <el-input v-model="form.materialCharacteristics" placeholder="请输入materialCharacteristics"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="recheckdays" prop="recheckdays">
              <el-input v-model="form.recheckdays" placeholder="请输入recheckdays"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    </div>
  </template>
  
  <script>
  import { listGOODS, getGOODS, delGOODS, addGOODS, updateGOODS } from "@/api/system/goods";
  
  export default {
    name: "GOODS",
    dicts: ['status', 'hazardous', 'sc_flag'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 物料表格数据
        GOODSList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          goodsId: null,
          goodsName: null,
          goodsShortName: null,
          pyName: null,
          goodsTypeId: null,
          SPECIFICATION: null,
          MODEL: null,
          PRICE: null,
          BARCODE: null,
          GLENGTH: null,
          GWIDTH: null,
          GHEIGHT: null,
          GVOLUME: null,
          scaleUnit: null,
          UNIT: null,
          warnUp: null,
          warnDown: null,
          produceArea: null,
          grossWeight: null,
          netWeight: null,
          providerId: null,
          HSNUMBER: null,
          ABC: null,
          HAZARDOUS: null,
          STORED: null,
          PERIOD: null,
          PERIODUNIT: null,
          ADDTAX: null,
          SEASON: null,
          TARIFFRATE: null,
          REMARK: null,
          STATUS: null,
          VERSION: null,
          IMG: null,
          createMan: null,
          createDate: null,
          updateMan: null,
          updateDate: null,
          scFlag: null,
          costPrice: null,
          isOpen: null,
          storageAreaId: null,
          zhFlag: null,
          SEMISTS: null
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          goodsId: [
            { required: true, message: "物料编号不能为空", trigger: "blur" }
          ],
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询物料列表 */
      getList() {
        this.loading = true;
        listGOODS(this.queryParams).then(response => {
          this.GOODSList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          goodsId: null,
          goodsName: null,
          goodsShortName: null,
          pyName: null,
          goodsTypeId: null,
          SPECIFICATION: null,
          MODEL: null,
          PRICE: null,
          BARCODE: null,
          GLENGTH: null,
          GWIDTH: null,
          GHEIGHT: null,
          GVOLUME: null,
          scaleUnit: null,
          UNIT: null,
          warnUp: null,
          warnDown: null,
          produceArea: null,
          grossWeight: null,
          netWeight: null,
          providerId: null,
          HSNUMBER: null,
          ABC: null,
          HAZARDOUS: null,
          STORED: null,
          PERIOD: null,
          PERIODUNIT: null,
          ADDTAX: null,
          SEASON: null,
          TARIFFRATE: null,
          REMARK: null,
          STATUS: null,
          VERSION: null,
          IMG: null,
          createMan: null,
          createDate: null,
          updateMan: null,
          updateDate: null,
          scFlag: null,
          costPrice: null,
          isOpen: null,
          storageAreaId: null,
          zhFlag: null,
          SEMISTS: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.goodsId)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加物料";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const goodsId = row.goodsId || this.ids
        getGOODS(goodsId).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改物料";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.goodsId != null) {
              updateGOODS(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addGOODS(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const goodsIds = row.goodsId || this.ids;
        this.$modal.confirm('是否确认删除物料编号为"' + goodsIds + '"的数据项？').then(function() {
          return delGOODS(goodsIds);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('system/GOODS/export', {
          ...this.queryParams
        }, `GOODS_${new Date().getTime()}.xlsx`)
      }
    }
  };
  </script>
  